#!/usr/bin/perl
use strict;
use Data::Dumper;
my $HOME = $ENV{HOME};
my $ssh_dir = $HOME."/.ssh/";
my $conf_file = $ssh_dir."config";
my $svn_dir = $ENV{PWD};
my $svn_conf = $svn_dir."/config";

unless (-f $svn_conf) {
	die("Unable to open $svn_conf!");
}

if (-l $conf_file) {
	print "Current config is a link.  Renaming to: $conf_file.prev.ln\n";
	system("mv $conf_file $conf_file.prev.ln");
} elsif (-f $conf_file) {
	print "Current config is a file.  Renaming to: $conf_file.prev\n";
	system("mv $conf_file $conf_file.prev");
}

system("ln -s $svn_conf $conf_file");
system("chmod 600 $svn_conf $conf_file");

chomp(my $svn = `which svn`);
if ( (-x $svn) && (! -f $HOME."/.vim_update.sh") ) {
	print "Highly advise adding this to crontab:\n\t";
	print "0 0 * * * $svn update $svn_dir\n";
}

